import request from '@/utils/request'

// 佣金规则列表
export function listCommissionRules(query) {
  return request({
    url: '/commission/rule/page',
    method: 'get',
    params: query
  })
}

// 获取所有可用佣金规则
export function listAllCommissionRules() {
  return request({
    url: '/commission/rule/list',
    method: 'get'
  })
}

// 获取佣金规则详情
export function getCommissionRule(id) {
  return request({
    url: `/commission/rule/${id}`,
    method: 'get'
  })
}

// 新增佣金规则
export function addCommissionRule(data) {
  return request({
    url: '/commission/rule',
    method: 'post',
    data: data
  })
}

// 修改佣金规则
export function updateCommissionRule(data) {
  return request({
    url: '/commission/rule',
    method: 'put',
    data: data
  })
}

// 删除佣金规则
export function deleteCommissionRule(id) {
  return request({
    url: `/commission/rule/${id}`,
    method: 'delete'
  })
}

// 更新佣金规则状态
export function changeCommissionRuleStatus(id, status) {
  return request({
    url: '/commission/rule/status',
    method: 'put',
    params: {
      id,
      status
    }
  })
}

// 佣金记录列表
export function listCommissions(query) {
  return request({
    url: '/commission/page',
    method: 'get',
    params: query
  })
}

// 计算订单佣金
export function calculateCommission(orderId) {
  return request({
    url: '/commission/calculate',
    method: 'post',
    params: {
      orderId
    }
  })
}

// 结算佣金
export function settleCommission(id) {
  return request({
    url: `/commission/settle/${id}`,
    method: 'put'
  })
}

// 批量结算佣金
export function settleBatchCommission(ids) {
  return request({
    url: '/commission/settle-batch',
    method: 'put',
    data: ids
  })
} 